import * as Types from './mutation-types' /* 必须有“./” */
export default {
  [Types.USER_LOGIN] (state, data) {
    if (data.userid) { // 保存了新的userid
      state.userid = data.userid // 保存新的userid
      state.photo = data.photo
      state.privilege = data.privilege
    }
  },
  [Types.USER_PHOTO] (state, photo) {
    state.photo = photo
  },
  [Types.USER_LOGOUT] (state) { // 用户注销
    state.userid = '' // 删除已有的userid
    state.photo = '/static/images/avator/nophoto.png'
    state.privilege = [] // 删除已有权限
  },
  [Types.CHECK_LOGIN] (state) {
    return state.userid !== '' || state.userid.length() > 0
  },
  [Types.JWT_TOKEN] (state, loginData) {
    console.log(loginData)
    state.token = loginData.token
    state.headerName = loginData.headerName
  }
}
